package com.xsoft.action;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import com.xsoft.formBean.LoginForm;

import struts.base.BaseActionForm;
import struts.annotation.ActionMapping;
import struts.annotation.FormBean;
import struts.base.BaseAction;

@ActionMapping(name="login", type="com.xsoft.action.LoginAction", path="/login", success="/view/loginSuccess.jsp", fail="/view/loginFail.jsp")
public class LoginAction implements BaseAction {

	/**
	 * 登录验证业务逻辑
	 * 返回model view
	 * 
	 */
	@Override
	public String execute(HttpServletRequest request, BaseActionForm form, Map<String, String> actionForward) {
		String forward_name="";
		String forward_url="";
		LoginForm loginForm=(LoginForm)form;
		String username = loginForm.getUsername();
		String password = loginForm.getPassword();
		if(username.equals("jeecg") && password.equals("123456")){
			forward_name="success";
			forward_url= actionForward.get(forward_name);
			request.setAttribute("username", username);
		}else{
			forward_name="fail";
			forward_url= actionForward.get(forward_name);
		}
		
		return forward_url;
	}
}
